<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>RBAC管理</title>
  <meta name="description" content="这是一个 table 页面">
  <meta name="keywords" content="作品分享">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />

  <link href="__PUBLIC__/css/amazeui.min.css" rel="stylesheet">
  <link href="__PUBLIC__/css/admin.css" rel="stylesheet">

  <link rel="stylesheet" type="text/css" href="__PUBLIC__/css/node.css">
  
  <script src="__PUBLIC__/js/jquery-2.1.1.js"></script>
  <script src="__PUBLIC__/js/amazeui.min.js"></script>

  <script type="text/javascript">

      $(function() {

        $('input[level=1]').click(function () {

          var inputs = $(this).parents('.app').find('dl input');
          $(this).prop('checked') ? inputs.prop('checked', 'checked') :
              inputs.removeAttr('checked');

        });

        $('input[level=2]').click(function(){
            var inputs = $(this).parents('dl').find('input');

            $(this).prop('checked') ? inputs.prop('checked', 'checked') :
              inputs.removeAttr('checked');
        });
      });

  </script>

</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
  以获得更好的体验！</p>
<![endif]-->

<header class="am-topbar admin-header">
  <div class="am-topbar-brand">
    <strong>作品分享</strong>/<small>后台管理</small>
  </div>

  <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

  <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

    <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
      <li class="am-dropdown" data-am-dropdown>
        <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
          <span class="am-icon-users">管理员，{:session('username')}</span>
        </a>
      </li>
      <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
    </ul>
  </div>
</header>

<div class="am-cf admin-main">
  <!-- sidebar start -->
  <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
      <ul class="am-list admin-sidebar-list">
        <li><a href="{:U('index/index')}"><span class="am-icon-home"></span> 首页</a></li>
        <li><a href="#"><span class="am-icon-table"></span> 网站信息</a></li>
        <!-- <li><a href="#"><span class="am-icon-pencil-square-o"></span> 权限管理</a></li>
 -->
        <li class="admin-parent">
          <a class="am-cf" data-am-collapse="{target: '#collapse-nav'}"><span class="am-icon-user"></span>  RBAC<span class="am-icon-angle-right am-fr am-margin-right"></span></a>
          <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav">
            <li><a href="{:U('Rbac/index')}"><span class="am-icon-user"></span> 用户列表<span></span></a></li>
            <li><a href="{:U('Rbac/role')}"><span class="am-icon-puzzle-piece"> 角色列表</span></a></li>
            <li><a href="{:U('Rbac/node')}"><span class="am-icon-th"></span> 节点列表</a></li>
            <li><a href="{:U('Rbac/addUser')}"><span class="am-icon-check"></span> 添加用户</a></li>
            <li><a href="{:U('Rbac/addRole')}"><span class="am-icon-check"></span> 添加角色</a></li>
            <li><a href="{:U('Rbac/addNode')}"><span class="am-icon-check"></span> 添加节点</a></li>
          </ul>
        </li>
        <li><a href="{:U('Login/logout')}"><span class="am-icon-sign-out"></span> 注销</a></li>
      </ul>

      <div class="am-panel am-panel-default admin-sidebar-panel">
        <div class="am-panel-bd">
          <p><span class="am-icon-bookmark"></span> 公告</p>
          <p>时光静好，与君语；细水流年，与君同。—— Amaze UI</p>
        </div>
      </div>

      <div class="am-panel am-panel-default admin-sidebar-panel">
        <div class="am-panel-bd">
          <p><span class="am-icon-tag"></span> wiki</p>
          <p>Welcome to the Amaze UI wiki!</p>
        </div>
      </div>
    </div>
  </div>
  <!-- sidebar end -->

  <!-- content start -->
  <div class="admin-content">

    <div class="am-cf am-padding">
      <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">RBAC</strong> / <small>配置权限</small></div>
    </div>
      
      <form action="{:U('Admin/Rbac/setAccess')}" method="post">
      <div id="wrap">
        <a href="{:U('Admin/Rbac/role')}" class="add-app">返回</a>

        <foreach name="node" item="app">
          <div class="app">
            <p>
              <strong>{$app.title}</strong>
              <input type="checkbox" name='access[]' value='{$app.id}_1' level='1' <if condition='$app["access"]'>checked='checked'</if> />
            <foreach name='app.child' item='action'>
              <dl>
                <dt>
                  <strong>{$action.title}</strong>
                  <input type="checkbox" name="access[]" value='{$action.id}_2' level='2'<if condition='$action["access"]'>checked='checked'</if>/>
                </dt>
                <foreach name='action.child' item='method'>
                  <dd>
                    <span>{$method.title}</span>
                    <input type="checkbox" name="access[]" value='{$method.id}_3' level='3'<if condition='$method["access"]'>checked='checked'</if>/>
                  </dd>
                </foreach>
              </dl>
            </foreach>
          </div>
          
        </foreach>
      </div>
      
      <input type="hidden" name="rid" value='{$rid}'/>
      <input type="submit" value='保存修改' style='display:block;margin:20px auto;cursor:pointer'>
      </form>
      
<footer>
  <hr>
  <p class="am-padding-left">作品管理</p>
</footer>

<!--[if lt IE 9]>
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->

</body>
</html>
